﻿using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace IFXplus.SmartStorage.Providers
{

    [GeneratedCode("wsdl", "2.0.50727.42")]
    [DebuggerStepThroughAttribute]
    [DesignerCategoryAttribute("code")]
    [WebServiceBindingAttribute(Name = "WebServiceStorageProviderStubSoap", Namespace = "http://smartstorage.ifxplus.com/")]
    public class WebServiceStorageProviderStub : SoapHttpClientProtocol
    {
        private WebServiceStorageProviderClientCredentials _ClientCredentials;
        private SendOrPostCallback InsertOperationCompleted;
        private SendOrPostCallback RemoveOperationCompleted;
        private SendOrPostCallback GetOperationCompleted;

        public WebServiceStorageProviderStub() : this("http://localhost/WebServiceStorageProvider.asmx") { }
        public WebServiceStorageProviderStub(string url) : this(url, string.Empty, string.Empty) { }
        public WebServiceStorageProviderStub(string url, string username, string password)
        {
            Url = url;
            ClientCredentials = new WebServiceStorageProviderClientCredentials(username, password);
        }

        public WebServiceStorageProviderClientCredentials ClientCredentials
        {
            get { return _ClientCredentials; }
            set { _ClientCredentials = value; }
        }

        public event InsertCompletedEventHandler InsertCompleted;
        public event RemoveCompletedEventHandler RemoveCompleted;
        public event GetCompletedEventHandler GetCompleted;

        [SoapHeaderAttribute("ClientCredentials")]
        [SoapDocumentMethodAttribute(RequestNamespace = "http://smartstorage.ifxplus.com/", ResponseNamespace = "http://smartstorage.ifxplus.com/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public void Insert(StorageEntry value)
        {
            Invoke("Insert", new object[] {value});
        }
        public IAsyncResult BeginInsert(StorageEntry value, AsyncCallback callback, object asyncState)
        {
            return BeginInvoke("Insert", new object[] {value}, callback, asyncState);
        }
        public void EndInsert(IAsyncResult asyncResult)
        {
            EndInvoke(asyncResult);
        }
        public void InsertAsync(StorageEntry value)
        {
            InsertAsync(value, null);
        }
        public void InsertAsync(StorageEntry value, object userState)
        {
            if (InsertOperationCompleted == null)
                InsertOperationCompleted = this.OnInsertOperationCompleted;
            InvokeAsync("Insert", new object[] {value}, InsertOperationCompleted, userState);
        }
        private void OnInsertOperationCompleted(object arg)
        {
            if (InsertCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                InsertCompleted(this, new AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        [SoapHeaderAttribute("ClientCredentials")]
        [SoapDocumentMethodAttribute(RequestNamespace = "http://smartstorage.ifxplus.com/", ResponseNamespace = "http://smartstorage.ifxplus.com/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public void Remove(string key)
        {
            Invoke("Remove", new object[] {key});
        }
        public IAsyncResult BeginRemove(string key, AsyncCallback callback, object asyncState)
        {
            return BeginInvoke("Remove", new object[] {key}, callback, asyncState);
        }
        public void EndRemove(IAsyncResult asyncResult)
        {
            EndInvoke(asyncResult);
        }
        public void RemoveAsync(string key)
        {
            RemoveAsync(key, null);
        }
        public void RemoveAsync(string key, object userState)
        {
            if (RemoveOperationCompleted == null)
                RemoveOperationCompleted = this.OnRemoveOperationCompleted;
            InvokeAsync("Remove", new object[] {key}, RemoveOperationCompleted, userState);
        }
        private void OnRemoveOperationCompleted(object arg)
        {
            if (RemoveCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                RemoveCompleted(this, new AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        [SoapHeaderAttribute("ClientCredentials")]
        [SoapDocumentMethodAttribute(RequestNamespace = "http://smartstorage.ifxplus.com/", ResponseNamespace = "http://smartstorage.ifxplus.com/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public StorageEntry Get(string key)
        {
            object[] results = Invoke("Get", new object[] {key});
            return (StorageEntry)results[0];
        }
        public IAsyncResult BeginGet(string key, AsyncCallback callback, object asyncState)
        {
            return BeginInvoke("Get", new object[] {key}, callback, asyncState);
        }
        public StorageEntry EndGet(IAsyncResult asyncResult)
        {
            object[] results = EndInvoke(asyncResult);
            return (StorageEntry)results[0];
        }
        public void GetAsync(string key)
        {
            GetAsync(key, null);
        }
        public void GetAsync(string key, object userState)
        {
            if (GetOperationCompleted == null)
                GetOperationCompleted = this.OnGetOperationCompleted;
            InvokeAsync("Get", new object[] {key}, GetOperationCompleted, userState);
        }
        private void OnGetOperationCompleted(object arg)
        {
            if (GetCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                GetCompleted(this, new GetCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        public new void CancelAsync(object userState)
        {
            base.CancelAsync(userState);
        }
    }

    [GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
    public delegate void InsertCompletedEventHandler(object sender, AsyncCompletedEventArgs e);

    [GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
    public delegate void RemoveCompletedEventHandler(object sender, AsyncCompletedEventArgs e);

    [GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
    public delegate void GetCompletedEventHandler(object sender, GetCompletedEventArgs e);

    [GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
    [DebuggerStepThroughAttribute]
    [DesignerCategoryAttribute("code")]
    public class GetCompletedEventArgs : AsyncCompletedEventArgs
    {
        private readonly object[] results;
        internal GetCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }
        public object Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return results[0];
            }
        }
    }
}